#include "Signal.h"
#include "SleepTimer.h"
#include "SignalInput.h"
#include <stdio.h>

Signal::Signal(SignalInput si)
	: _input(si), _time(0)
{
	
};

void Signal::run()
{
	SleepTimer t1;

	while(1)
	{
		fflush(stdout);
		update();
		
		_history.store(_reading); 
		t1.sleep(25);
	}
}

void Signal::update()
{
	_input.update();
	_reading.value = _input.getValue();
	_reading.timestamp = _time++;
} 

History* Signal::getHistory()
{
	return &_history;
}
